﻿using System;
using DALHelper.DAL;

namespace DALHelper.Business
{
    public class BusinessManager : IDisposable
    {
        private DALManager m_DataManager;

        #region properties
        public Room Room
        {
            get;
            set;
        }

        public RoomCategory RoomCategory
        {
            get;
            set;
        }

        public Transaction Transaction
        {
            get;
            set;
        }

        public TransDetail TransDetail
        {
            get;
            set;
        }

        public UserManager UserManager
        {
            get;
            set;
        } 
        #endregion

        /// <summary>
        /// construct Business and DA layers with default SQL login options
        /// </summary>
        public BusinessManager() : this("localhost", "QLDatPhong", "sa", "123456")
        {

        }

        /// <summary>
        /// Construct Business and DA layers.
        /// </summary>
        /// <param name="sServerAddr"></param>
        /// <param name="sUserName"></param>
        /// <param name="sPass"></param>
        public BusinessManager(string sServerAddr, string sDatabase, string sUserName, string sPass)
        {
            m_DataManager = new DALManager(sServerAddr, sDatabase, sUserName, sPass);

            Room = new Room(m_DataManager);
            RoomCategory = new RoomCategory(m_DataManager);
            Transaction = new Transaction(m_DataManager);
            TransDetail = new TransDetail(m_DataManager);
            UserManager = new UserManager(m_DataManager);
        }

        #region IDisposable Members

        public void Dispose()
        {
            m_DataManager.Dispose();
        }

        #endregion
    }
}
